/**
 * Copyright (c) 2019, ShangHai YTO Co., Ltd.
 * All right reserved.
 *
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF YTO
 * CO., LTD.  THE CONTENTS OF THIS FILE MAY NOT BE DISCLOSED
 * TO THIRD PARTIES, COPIED OR DUPLICATED IN ANY FORM, IN WHOLE OR IN PART,
 * WITHOUT THE PRIOR WRITTEN PERMISSION OF YTO
 * CO., LTD.
 */
package org.sc.xl.algorithm.easyexcel226;

import lombok.Data;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.xssf.usermodel.XSSFColor;

/**
 * @description: TODO 请在此添加描述
 * @reason: TODO ADD REASON(可选)
 * @author FXL
 *
 * @date 2024/10/19 13:00 
 * @since JDK 1.8
 */
@Data
public class StyleModel {

    /**
     * sheet名称
     */
    private String sheetName;
    /**
     * 列索引
     */
    private int colIndex;
    /**
     * 行索引
     */
    private int rowIndex;
    /**
     * 背景颜色
     */
    private Object backgroundColor;

    /**
     * 生成背景颜色样式信息
     *
     * @param sheetName       sheet页名称
     * @param rowIndex        行号
     * @param columnIndex     列号
     * @param backgroundColor 背景颜色
     * @return
     */
    public static StyleModel createBackgroundColorCellStyleModel(String sheetName, int rowIndex, int columnIndex, Object backgroundColor) {
        StyleModel styleModel = new StyleModel();
        //sheet页名称
        styleModel.setSheetName(sheetName);
        //行号
        styleModel.setRowIndex(rowIndex);
        //列号
        styleModel.setColIndex(columnIndex);
        //背景颜色
        backgroundColor = backgroundColor != null && (backgroundColor instanceof IndexedColors == false && backgroundColor instanceof XSSFColor == false) ? null : backgroundColor;
        styleModel.setBackgroundColor(backgroundColor);
        return styleModel;
    }
}
